<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="/layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">Usuário</f:facet>

        <s:decorate id="nome" template="/layout/display.xhtml">
            <ui:define name="label">Nome</ui:define>
            <h:outputText value="#{usuarioHome.instance.nome}"/>
        </s:decorate>
        
        <s:decorate id="dataCadastro" template="/layout/display.xhtml">
            <ui:define name="label">Data de Cadastro</ui:define>
            <h:outputText value="#{usuarioHome.instance.dataCadastro.time}"/>
        </s:decorate>
        
        <s:decorate id="email" template="/layout/display.xhtml">
            <ui:define name="label">E-mail</ui:define>
            <h:outputText value="#{usuarioHome.instance.email}"/>
        </s:decorate>
        
        <s:decorate id="status" template="/layout/display.xhtml">
            <ui:define name="label">Status</ui:define>
            <h:outputText value="#{usuarioHome.instance.status}"/>
        </s:decorate>
        
        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/resources/UsuarioEdit.xhtml"
                    id="edit"
                 value="Editar"/>

        <s:button view="/resources/#{empty usuarioFrom ? 'UsuarioList' : usuarioFrom}.xhtml"
                    id="done"
                 value="Concluído"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Categoria</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="categoriaChildren">

        <h:outputText value="Não existe nenhuma Categoria cadastrada."
                   rendered="#{empty usuarioHome.categoria}"/>

        <rich:dataTable value="#{usuarioHome.categoria}"
                       var="_categoria"
                  rendered="#{not empty usuarioHome.categoria}"
                rowClasses="odd,even"
                        id="categoriaTable">
            
            <rich:column sortBy="#{_categoria.nome}">
                <f:facet name="header">Nome</f:facet>
                <h:outputText value="#{_categoria.nome}"/>
            </rich:column>
            <rich:column sortBy="#{_categoria.descricao}">
                <f:facet name="header">Descrição</f:facet>
                <h:outputText value="#{_categoria.descricao}"/>
            </rich:column>
            <rich:column style="text-align: center;">
                <f:facet name="header">Opções</f:facet>
                <s:link id="selectcategoria"
                     value="Selecionar"
                      view="/resources/Categoria.xhtml">
                    <f:param name="categoriaId"
                            value="#{_categoria.id}"/>
                    <f:param name="categoriaFrom" value="Usuario"/>
                </s:link>
            </rich:column>
        </rich:dataTable>

        <br clear="left"/>
       
        <rich:datascroller for="categoriaTable" renderIfSinglePage="false" />
       
    </h:form>

    <div class="actionButtons">
        <s:button
               value="Nova Categoria"
                view="/resources/CategoriaEdit.xhtml">
            <f:param name="usuarioId"
                    value="#{usuarioHome.instance.id}"/>
            <f:param name="categoriaFrom" value="Usuario"/>
        </s:button>
    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Subgrupo</h:panelGroup>
        </f:facet>
    <div class="association" id="subGrupoParent">

        <h:outputText value="Não existe nenhum Subgrupo associado."
                   rendered="#{usuarioHome.instance.subGrupo == null}"/>

        <rich:dataTable var="_subGrupo"
                   value="#{usuarioHome.instance.subGrupo}"
                rendered="#{usuarioHome.instance.subGrupo != null}"
              rowClasses="odd,even"
                      id="subGrupoTable">
             <h:column>
                <f:facet name="header">Nome</f:facet>
                <h:outputText value="#{_subGrupo.nome}"/>
            </h:column>
            <h:column>
                <f:facet name="header">E-mail</f:facet>
                <h:outputText value="#{_subGrupo.email}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Descrição</f:facet>
                <h:outputText value="#{_subGrupo.descricao}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Data de Cadastro</f:facet>
                <h:outputText value="#{_subGrupo.dataCadastro.time}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status</f:facet>
                <h:outputText value="#{_subGrupo.status}"/>
            </h:column>
            <h:column styleClass="action">
                <f:facet name="header">Opções</f:facet>
                <s:link id="viewsubGrupo"
                     value="Ver"
                      view="/resources/SubGrupo.xhtml">
                    <f:param name="subGrupoId"
                           value="#{_subGrupo.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
